﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using CarbonMeter;

namespace CarbonMeter
{
    class CustomDataGridView : DataGridView
    {
        
        protected override void OnRowPostPaint(DataGridViewRowPostPaintEventArgs e)
        {
            base.OnRowPostPaint(e);
            int RowNumWidth = this.RowCount.ToString().Length;
            StringBuilder RowNumber = new StringBuilder(RowNumWidth);
            RowNumber.Append(e.RowIndex + 1);
            while (RowNumber.Length < RowNumWidth)
                RowNumber.Insert(0, "0");
            SizeF Sz = e.Graphics.MeasureString(RowNumber.ToString(), this.Font);

            if (this.RowHeadersWidth < (int)(Sz.Width + 20))
                this.RowHeadersWidth = (int)(Sz.Width + 20);
            e.Graphics.DrawString(RowNumber.ToString(), Font, SystemBrushes.ControlText,
                e.RowBounds.Location.X + 15, e.RowBounds.Location.Y + (e.RowBounds.Height - Sz.Height) / 2);
            
        }
        protected override void OnCellPainting(DataGridViewCellPaintingEventArgs e)
        {

            /*try
            {
                 if (e.ColumnIndex == 4 && Parent.Text.Equals("Ürünler"))
                {
                    if(Boolean.Parse(e.Value.ToString()) == false && e.RowIndex != Rows.Count)
                    Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.Red;
                }
            }
            catch (Exception)
            {

               
            }*/
            base.OnCellPainting(e);
        }
       
    }
}
